package com.lvmama.rhino.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lvmama.rhino.entity.RequestSearchParam;
import com.lvmama.rhino.mapper.FlowSearchMapper;
import com.lvmama.rhino.pojo.search.FlowSearchArrivalKey;
import com.lvmama.rhino.pojo.search.FlowSearchFilter;
import com.lvmama.rhino.pojo.search.FlowSearchFilterCondition;
import com.lvmama.rhino.pojo.search.FlowSearchJump;
import com.lvmama.rhino.pojo.search.FlowSearchKey;
import com.lvmama.rhino.pojo.search.FlowSearchKeyType;
import com.lvmama.rhino.pojo.search.FlowSearchPaging;
import com.lvmama.rhino.pojo.search.FlowSearchResult;
import com.lvmama.rhino.pojo.search.FlowSearchStation;
import com.lvmama.rhino.pojo.search.FlowSearchStatistics;
import com.lvmama.rhino.service.FlowSearchService;

/**
 * @ClassName: FlowSearchServiceImpl
 * @Description: 搜索相关接口实现
 * @author shenlinli
 * @param <E>
 * @date 2017年3月13日 下午2:26:58
 */
@Service
public class FlowSearchServiceImpl implements FlowSearchService {
	@Autowired
	private FlowSearchMapper flowSearchMapper;

	@Override
	public List<FlowSearchStatistics> getSearchFlowByDate(
			RequestSearchParam searhParam) {
		// 查询搜索流量根据日期 渠道
		return flowSearchMapper.queryFlowByDate(searhParam);
	}

	@Override
	public List<FlowSearchStatistics> getSearchFlowByChannel(
			RequestSearchParam searhParam) {
		// 查询搜索流量根据渠道
		return flowSearchMapper.queryFlowByChannel(searhParam);
	}

	@Override
	public List<FlowSearchKeyType> getKeyByType(RequestSearchParam searhParam) {
		// 查询搜索关键字 点击类型
		return flowSearchMapper.queryKeyByType(searhParam);
	}

	@Override
	public List<FlowSearchKeyType> getKeyByDate(RequestSearchParam searhParam) {
		// 查询日期 查看各搜索关键字点击类型的pv
		return flowSearchMapper.queryKeyByDate(searhParam);
	}

	@Override
	public PageInfo<FlowSearchKey> getKeyByAmount(RequestSearchParam searhParam) {
		// 根据搜索次数查询搜索信息
		PageHelper.startPage(searhParam.getPage_currentNum(),
				searhParam.getPage_size());
		PageInfo<FlowSearchKey> page = new PageInfo<FlowSearchKey>(
				flowSearchMapper.queryKeyByAmount(searhParam));
		return page;
	}

	@Override
	public List<FlowSearchKey> getDetailByStation(RequestSearchParam searhParam) {
		return flowSearchMapper.queryDetailByStation(searhParam);
	}

	@Override
	public List<FlowSearchKey> getDetailByType(RequestSearchParam searhParam) {
		return flowSearchMapper.queryDetailByKey(searhParam);
	}

	@Override
	public List<FlowSearchPaging> getPagingByCategory(
			RequestSearchParam searhParam) {
		return flowSearchMapper.queryPagingByCategory(searhParam);
	}

	@Override
	public List<FlowSearchPaging> getPagingByPageCode(
			RequestSearchParam searhParam) {
		return flowSearchMapper.queryPagingByPageCode(searhParam);
	}

	@Override
	public List<FlowSearchStation> getStations() {
		return flowSearchMapper.queryStationList();
	}

	@Override
	public List<FlowSearchResult> getResultByCategory(
			RequestSearchParam searhParam) {
		return flowSearchMapper.queryResultByCategory(searhParam);
	}

	@Override
	public List<FlowSearchResult> getResultByDate(RequestSearchParam searhParam) {
		return flowSearchMapper.queryResultByDate(searhParam);
	}

	@Override
	public PageInfo<FlowSearchResult> getResultByKey(
			RequestSearchParam searhParam) {
		PageHelper.startPage(searhParam.getPage_currentNum(),
				searhParam.getPage_size());
		PageInfo<FlowSearchResult> page = new PageInfo<FlowSearchResult>(
				flowSearchMapper.queryResultByKey(searhParam));
		return page;
	}

	@Override
	public List<FlowSearchFilter> getFilterList(RequestSearchParam searhParam) {
		return flowSearchMapper.queryFilterByCondition(searhParam);
	}

	@Override
	public List<FlowSearchArrivalKey> getKeyByCategory(
			RequestSearchParam searhParam) {
		return flowSearchMapper.queryKeyByCategory(searhParam);
	}

	@Override
	public List<FlowSearchArrivalKey> getKeyByKeyword(
			RequestSearchParam searhParam) {
		return flowSearchMapper.queryKeyByKeyword(searhParam);
	}

	@Override
	public List<FlowSearchArrivalKey> getKeyByXgword(
			RequestSearchParam searhParam) {
		List<FlowSearchArrivalKey> keyXgwordList = flowSearchMapper
				.queryKeyByXgword(searhParam);
		return keyXgwordList;
	}

	@Override
	public List<FlowSearchJump> getJumpByCategory(RequestSearchParam searhParam) {
		return flowSearchMapper.queryJumpDeByCategory(searhParam);
	}

	@Override
	public List<FlowSearchJump> getJumpByDate(RequestSearchParam searhParam) {
		return flowSearchMapper.queryJumpDeByDate(searhParam);
	}

	@Override
	public List<FlowSearchJump> getMoJumpByResult(RequestSearchParam searhParam) {
		return flowSearchMapper.queryJumpDeByResult(searhParam);
	}

	@Override
	public List<FlowSearchJump> getSwitchByCategory(
			RequestSearchParam searchParam) {
		return flowSearchMapper.querySwitchByCategory(searchParam);
	}

	@Override
	public List<FlowSearchJump> getSwitchByDate(RequestSearchParam searchParam) {
		return flowSearchMapper.querySwitchByDate(searchParam);
	}

	@Override
	public List<FlowSearchJump> getSwitchByResult(RequestSearchParam searhParam) {
		return flowSearchMapper.querySwitchByResult(searhParam);
	}

	@Override
	public FlowSearchStation getStationNameById(RequestSearchParam searhParam) {
		return flowSearchMapper.queryStationNameById(searhParam);
	}

	@Override
	public FlowSearchFilterCondition getFilterNameByCode(
			FlowSearchFilterCondition param) {
		return flowSearchMapper.queryFilterNameByCode(param);
	}

	@Override
	public boolean insertFilter(FlowSearchFilterCondition param) {
		return flowSearchMapper.insertFilter(param);
	}

}
